
/****
 * Copyright (C) 2006 dNux Team
 *                                                            ****
 * This program is free software; you can redistribute it and/or *
 * modify under the terms of the GNU General Public License as   *
 * published by the Free Software Foundation;                    *
 * either version 2 of the License.                              *
 *                                                               *
 * This program is distributed in the hope that it will be       *
 * useful, but WITHOUT ANY WARRANTY; without even the implied    *
 * warranty of without even the implied waranty of               *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.          *
 * See the GNU General Public License for more details.          *
 *                                                               *
 * You should have received a copy of the                        *
 * GNU General Public License                                    *
 * along with this program; if not, write to the                 *
 * Free Software Foundation, Inc.,                               *
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. *
 *                                                               *
 ****                                                         ****/

#include "dpkg.h"

d_pkg_t *
d_pkg_new()
{
  d_pkg_t *pkg;

  pkg = (d_pkg_t *) malloc(sizeof(d_pkg_t));
  if (pkg) {
    pkg->install_prefix = NULL;
    pkg->file = NULL;
    pkg->name = NULL;
    pkg->version = NULL;
  }

  return pkg;
}

void
d_pkg_free(d_pkg_t **pkg)
{
  d_pkg_t *p = *pkg;
  if (p) {
    if (p->install_prefix) free(p->install_prefix);
    if (p->name) free(p->name);
    if (p->version) free(p->version);
    if (p->file) free(p->file);
    free(p);
  }
  *pkg = NULL;
}

void
d_pkg_set_install_prefix(d_pkg_t *pkg, char *prefix)
{
  pkg->install_prefix = strdup(prefix);
}

void
d_pkg_set_file(d_pkg_t *pkg, char *file)
{
  pkg->file = strdup(file);
}

void
d_pkg_set_name(d_pkg_t *pkg, char *name)
{
  pkg->name = strdup(name);
}

void
d_pkg_set_version(d_pkg_t *pkg, char *version)
{
  pkg->version = strdup(version);
}
